Plotting confirmed SARS–CoV–2 infections
Author: Josef Heinen
Required packages: PlutoUI, GR
You may have to comment out the Pluto part, if you are running the script on a remote web server. If you are running the script in a local notebook server, you will be able to pan/zoom the plot and display information when hovering over the data points.
xxxxxxxxxx
8
1
md"""
2
## Plotting confirmed SARS–CoV–2 infections
3
### Author: [Josef Heinen](https://github.com/jheinen)
4
​
5
#### Required packages: PlutoUI, GR
6
​
7
You may have to comment out the Pluto part, if you are running the script on a remote web server. If you are running the script in a local notebook server, you will be able to pan/zoom the plot and display information when hovering over the data points.
8
"""
xxxxxxxxxx
9
1
begin
2
using DelimitedFiles
3
using PlutoUI
4
​
5
ENV["GRDISPLAY"] = "pluto" # see note above
6
using GR
7
8
GR.js.init_pluto() # see note above
9
end
xxxxxxxxxx
4
1
begin
2
url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"
3
download(url, "covid19.csv")
4
end;
xxxxxxxxxx
5
1
begin
2
data = readdlm("covid19.csv", ',')
3
ncountries, ncols = size(data)
4
ndays = ncols - 4
5
end;
xxxxxxxxxx
10
1
begin
2
cummulated = Dict()
3
for i in 1:ncountries
4
country = data[i,2]
5
if country in countries
6
if !haskey(cummulated, country) cummulated[country] = zeros(ndays) end
7
cummulated[country] .+= collect(data[i,5:end])
8
end
9
end
10
end
xxxxxxxxxx
4
1
begin
2
day = collect(Float64, 1:ndays);
3
confirmed = hcat([cummulated[country] for country in countries]...)
4
end;
Here you can select the country you want to see.
You can select multiple countries or all countries with Cmd
+A
.
xxxxxxxxxx
5
1
md"""
2
Here you can select the country you want to see.
3
​
4
You can select multiple countries or all countries with `Cmd`+`A`.
5
"""
xxxxxxxxxx
1
1
countries MultiSelect(["Germany", "Austria", "Belgium", "Netherlands", "France", "Italy", "Spain", "US"], default=["Germany"])
xxxxxxxxxx
3
1
plot(day, confirmed, xlim=(0, ndays+1), ylim=(10, 20_000_000), ylog=true,
2
title="Confirmed SARS–CoV–2 infections", xlabel="Day", ylabel="Confirmed",
3
labels=countries, location=4)